package com.arqui.admmon_module.client.core.main;

import com.arqui.admmon_module.client.place.NameTokens;
import com.gwtplatform.mvp.client.Presenter;
import com.gwtplatform.mvp.client.View;
import com.gwtplatform.mvp.client.annotations.ContentSlot;
import com.gwtplatform.mvp.client.annotations.ProxyCodeSplit;
import com.gwtplatform.mvp.client.proxy.PlaceManager;
import com.gwtplatform.mvp.client.proxy.PlaceRequest;
import com.gwtplatform.mvp.client.proxy.Proxy;
import com.gwtplatform.mvp.client.proxy.RevealContentEvent;
import com.gwtplatform.mvp.client.proxy.RevealContentHandler;
import com.google.inject.Inject;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.shared.EventBus;
import com.google.gwt.event.shared.GwtEvent.Type;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.HTMLPanel;

public class OptionPresenter extends
		Presenter<OptionPresenter.MyView, OptionPresenter.MyProxy> {
	
	@ContentSlot 
	public static final Type<RevealContentHandler<?>> SLOT_content = new Type<RevealContentHandler<?>>();

	@Inject	PlaceManager placeManager;
	
	public interface MyView extends View {
		
		public Button getButtonBrand();

		public Button getButtonSystem();

		public HTMLPanel getContentPanel();
		
		public Button getButtonEvents();
	}

	@ProxyCodeSplit
	public interface MyProxy extends Proxy<OptionPresenter> {
	}

	@Inject
	public OptionPresenter(final EventBus eventBus, final MyView view,
			final MyProxy proxy) {
		super(eventBus, view, proxy);
	}

	@Override
	protected void revealInParent() {
		RevealContentEvent.fire(this, HeaderPresenter.SLOT_content, this);
	}

	@Override
	protected void onBind() {
		super.onBind();
	}
	
	@Override
	protected void onReset() {
		super.onReset();
		
		getView().getButtonBrand().addClickHandler(new ClickHandler() {
			@Override
			public void onClick(ClickEvent event) {
				PlaceRequest request = new PlaceRequest(NameTokens.brandadm);
				placeManager.revealPlace(request);
			}
		});
		
		getView().getButtonSystem().addClickHandler(new ClickHandler() {
			@Override
			public void onClick(ClickEvent event) {
				PlaceRequest request = new PlaceRequest(NameTokens.activitycluster);
				placeManager.revealPlace(request);
			}
		});
		
		getView().getButtonEvents().addClickHandler(new ClickHandler() {
			@Override
			public void onClick(ClickEvent event) {
				PlaceRequest request = new PlaceRequest(NameTokens.events);
				placeManager.revealPlace(request);
			}
		});
		
	}
}
